﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.ServiceModel;
using NLog;

namespace PUZZLEgestServer
{
    partial class PUZZLEgestWindowsService : ServiceBase
    {
        private static Logger logger = LogManager.GetCurrentClassLogger();
        private static ServiceHost host = null;

        public PUZZLEgestWindowsService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            Program.StartServices();

            //if (host != null)
            //{
            //    host.Close();
            //}

            //host = new ServiceHost(typeof(PUZZLEgestServer.SVC.PUZZLEgestService));

            //try
            //{
            //    host.Open();
            //    logger.Info("Service is on");
            //}
            //catch (Exception ex)
            //{
            //    logger.Info("Service failed to start");
            //}
        }

        protected override void OnStop()
        {
            if (host != null)
            {
                host.Close();
                host = null;
            }
        }
    }
}
